home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / co256_05.zip / VIRTSCRN.PAS < prev   
Pascal/Delphi Source File  |  1993-12-19  |  2KB  |  61 lines

  1. program VirtualScreenExample;
  2.  
  3. uses col256,crt;
  4.  
  5. const xVRes=400; { resolution of the virtual screen                 }
  6.       yVRes=300;
  7.  
  8.       xRes =320; { resolution of the CRT display (displayed screen) }
  9.       yRes =240;
  10.       ModeID=M320x240;
  11.  
  12. var x,y,xm,ym,i :integer;
  13.     xVis,yVis   :integer;
  14.  
  15. begin
  16.  EnterGraphMode(ModeID);
  17.  SetVirtualScreen(xVRes,yVRes);
  18.  
  19.  { draw some stuff on the screen (page 0) }
  20.  xm:=xMax div 2; ym:=yMax div 2;
  21.  for x:=xMin to xMax do begin line_(xm,ym,x,yMin,i); inc(i); end;
  22.  for y:=yMin to yMax do begin line_(xm,ym,xMax,y,i); inc(i); end;
  23.  for x:=xMax downto xMin do begin line_(xm,ym,x,yMax,i); inc(i); end;
  24.  for y:=yMax downto yMin do begin line_(xm,ym,xMin,y,i); inc(i); end;
  25.  
  26.  { draw some stuff on the screen (page 1) }
  27.  SetActivePage(1); SetVisualPage(1);
  28.  for i:=0 to xm do rectangle(xm-i,ym-i,xm+i,ym+i,i);
  29.  SetActivePage(0);
  30.  
  31.  { pan around }
  32.  i:=1;
  33.  repeat
  34.   case readkey of
  35.    '4': dec(xVis,i);    { emulate cursor on numeric keypad }
  36.    '6': inc(xVis,i);
  37.    '8': dec(yVis,i);
  38.    '2': inc(yVis,i);
  39.  
  40.    '7': begin dec(xVis,i); dec(yVis,i); end;
  41.    '1': begin dec(xVis,i); inc(yVis,i); end;
  42.    '3': begin inc(xVis,i); inc(yVis,i); end;
  43.    '9': begin inc(xVis,i); dec(yVis,i); end;
  44.  
  45.    '0': SwitchPages;
  46.  
  47.    '+': inc(i);                              { 'accelerate' }
  48.    '-': begin dec(i); if i<1 then i:=1; end; { 'decelerate' }
  49.  
  50.    #27: break;        { press ESC to exit program }
  51.   end;
  52.   if xVis>(xVRes-xRes) then xVis:=(xVRes-xRes); { do some clipping }
  53.   if xVis<0            then xVis:=0;
  54.   if yVis>(yVRes-yRes) then yVis:=(yVRes-yRes); { but it's not necessary }
  55.   if yVis<0            then yVis:=0;
  56.  
  57.   SetVisualScreen(xVis,yVis);
  58.  until false;
  59.  
  60.  ExitGraphMode;
  61. end.